/****** Object:  Stored Procedure [dbo].spThanhToanGetList Script Date: 6/23/2012 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[spGetAllThanhToanBySoPX]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[spGetAllThanhToanBySoPX]
GO

/******************************************************************************
**		Change History
*******************************************************************************
**		Date:		Author:					Description:
**		--------	--------				-----------------------------------
**		19/06/2012	SongTM					Innit created
*******************************************************************************/

CREATE PROCEDURE [dbo].[spGetAllThanhToanBySoPX]
(
	@SoPX nvarchar(14)
)

WITH ENCRYPTION
AS

SELECT
	tbl_ChiTietPhieuXuat.*,
	[tbl_ThanhToan].MaTT,
	[tbl_ThanhToan].NgayTT,
	[tbl_ThanhToan].PhuongThucTT,
	[tbl_ThanhToan].SoTien,
	[tbl_ThanhToan].GhiChu,
	tbl_LuuKho.MaThuoc,
	tbl_LuuKho.SoLo
FROM
	[tbl_ThanhToan] INNER JOIN tbl_ChiTietPhieuXuat ON [tbl_ThanhToan].MaCTPX = tbl_ChiTietPhieuXuat.MaCTPX
	INNER JOIN tbl_LuuKho ON tbl_ChiTietPhieuXuat.MaLuuKho=tbl_LuuKho.MaLuuKho
WHERE 
  tbl_ChiTietPhieuXuat.SoPX = @SoPX
GO

--GRANT EXECUTE ON [dbo].[spThanhToanGetList] TO [sa]
--GO
